/******************************************************************************
//             INTEL CORPORATION PROPRIETARY INFORMATION
//  This software is supplied under the terms of a license agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in accordance with the terms of that agreement.
//    Copyright(c) 2001 Intel Corporation. All Rights Reserved.
//
//  VSS: 
//     $Workfile: $
//     $Revision: $
//     $Date:     $
//     $Archive:  $
//
//  Description:
//
//  History:
//     Date        Author        Changes
//     2001/8/7   Jerry Hu       Created  (Version 0.1)
//
********************************************************************************/
#ifndef _DIB_H
#define _DIB_H

#ifdef  __cplusplus
extern "C" {
#endif

#ifndef TRUE
#define TRUE 1
#endif

#ifndef FALSE
#define FALSE 0
#endif

/*---------------------------------------------------------------------------*/
#define BM              0x424D
#define BI_RGB          0L
#define BI_RLE8         1L
#define BI_RLE4         2L
#define BI_BITFIELDS    3L

/*---------------------------------------------------------------------------*/
#define WRITE_INT8(value, offset, stream)                    \
    {                                                        \
        (stream)[offset]   = (Ipp8u)(value);                 \
    }

#define WRITE_INT16(value, offset, stream)                   \
    {                                                        \
        register int nTemp=(value);                          \
        (stream)[offset]   = (Ipp8u)((nTemp >> 8) & 0xff);   \
        (stream)[offset+1] = (Ipp8u)(nTemp & 0xff);          \
    }

#define WRITE_INT32(value, offset, stream)                   \
    {                                                        \
        register int nTemp=(value);                          \
        (stream)[offset]   = (Ipp8u)((nTemp >> 24) & 0xff);  \
        (stream)[offset+1] = (Ipp8u)((nTemp >> 16) & 0xff);  \
        (stream)[offset+2] = (Ipp8u)((nTemp >> 8) & 0xff);   \
        (stream)[offset+3] = (Ipp8u)(nTemp & 0xff);          \
    }

#define READ_INT8(offset, stream)                            \
    ((Ipp8u)(stream)[offset])

#define READ_INT16(offset, stream)                           \
    ((Ipp16u)(stream)[offset+1]|((Ipp16u)(stream)[offset]<<8))

#define READ_INT32(offset, stream)	( (((Ipp32u)(stream)[offset+3])&0xff)|((((Ipp32u)(stream)[offset+2])<<8)&0xff00)|    \
                                        ((((Ipp32u)(stream)[offset+1])<<16)&0xff0000)|((((Ipp32u)(stream)[offset])<<24)&0xff000000) )

/*---------------------------------------------------------------------------*/
typedef struct _MDIBSPEC
{
    int       nWidth;
    int       nHeight;
    int       nStep;
    int       nPrecision;
    int       nBitsPerpixel;
    int       nNumComponent;
    int       nClrMode;
    int       nDataSize;
    Ipp8u     *pBitmapData;
} MDIBSPEC;

/*---------------------------------------------------------------------------*/

int ReadDIBFile(MDIBSPEC *pDIBSpec, FILE *file);
int WriteDIBFile(MDIBSPEC *pDIBSpec, FILE *file);
void DestoryDIB(MDIBSPEC *pDIBSpec);

#ifdef  __cplusplus
}
#endif

#endif
/* EOF */

